<template>
    <div>
        <script :id=id type="text/plain"></script>
    </div>
</template>
<script>
export default {
    name: 'UE',
    data () {
        return {
            editor: null
        }
    },
    props: {
        config: {
            type: Object
        },
        id: {
            type: String
        },
        content: {
            type: String
        }
    },
    mounted () {
        const _this = this
        // eslint-disable-next-line no-undef
        this.editor = window.UE.getEditor(_this.id, _this.config)
        _this.editor.addListener('ready', function () {
            _this.editor.setContent(_this.content) // 确保UE加载完成后，放入内容。
        })
    },
    methods: {
        getUEContent () { // 获取内容方法
            return this.editor.getContent()
        }
        // _initEditor () { // 初始化
        //     const _this = this
        //     this.editor = window.UE.getEditor(this.id, this.config)
        //     _this.editor.addListener('ready', function () {
        //         _this.editor.setContent(_this.content) // 确保UE加载完成后，放入内容。
        //     })
        // },
    },
    destroyed () {
        this.editor.destroy()
    }
}

</script>
